home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00a.txt
/
000069_icon-group-sender _Mon Apr 17 13:31:54 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id NAA09054
for icon-group-addresses; Mon, 17 Apr 2000 13:31:31 -0700 (MST)
Message-Id: <200004172031.NAA09054@baskerville.CS.Arizona.EDU>
From: "Frank J. Lhota" <NOSPAM.Frank.Lhota@lexma.meitech.com>
X-Newsgroups: comp.lang.icon
Subject: Re: Reversible assignment really reversible ?
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-Mimeole: Produced By Microsoft MimeOLE V5.00.2919.6600
Date: Mon, 17 Apr 2000 15:33:47 -0000
X-Trace: client 956000040 38.163.203.81 (Mon, 17 Apr 2000 15:34:00 EDT)
To: icon-group@optima.CS.Arizona.EDU
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
> Although I appreciate all replies explaining the pitfalls of
co-expressions
> (maybe someone could also explain the INFIX @-operator, I always wondered
> about that one too), I'm still puzzled by the implementation of reversible
> assignment.
>
#---------------------------------------------------------------------------
---
> procedure revass(a,b) # pardon the expression
> local c
> c:=a
> suspend ((a:=b) | ((a:=c) & (&fail)))
> end ######
>
#---------------------------------------------------------------------------
---
> procedure myrevass(a,b)
> local c
> c:=a
> suspend ((a:=b) | ((a:=c) )) # &(&fail)))
> end #######
>
#---------------------------------------------------------------------------
---
>
> Which considerations (if any ;-) led to picking the first
> implementation ?
The idea behind reversible assignment is to provide data backtracking. If we
execute
i := 1;
text ? {
(i := 3) &
(j := (i < find("q")))
}
and the expression (i < find("q")) fails, i will end up with the value 3. We
will backtrack to the expression (i := 3), but normal assignment is not a
generator, and so the previous value of i is not restored. Assume that we do
not want the scanning expression to change i unless it succeeds. We can get
the desired effect by using reversable assignment.
i := 1;
text ? {
(i <- 3) &
(j := (i < find("q")))
}
Now if (i < find("q")) succeeds (for example, if text is "unique"), the
assignment of 3 to i remains in effect, and if (i < find("q")) fails, the
old value of i is restored.
If I understand your question correctly, you are wondering why reversible
assignment fails after resumption. The reason for this is that it would have
an undesired effect on control backtracking. Consider the scanning
expression above, where text is "queen":
(i <- 3) assigns 3 to i and suspends;
(j < find("q")) fails, so we resume the most recently suspended
expression;
(i <- 3) is resumed, so i gets its previous value (1);
Now if (i <- 3) were to succeed after being resumed, goal-driven evaluation
requires that we evaluate (i < find("q")) again, this time with i=1. This
evaluation would succeed, and therefor the whole scanning expression would
succeed, giving j=1. Clearly, this is not what you wanted.